'use strict';
// 员工 列表
module.exports = {
  up: async (queryInterface, Sequelize) => {
    const { INTEGER, STRING, DATE, ENUM } = Sequelize;
    // 创建表
    await queryInterface.createTable('admin_user', {
      id: {
        type: INTEGER(30).UNSIGNED,
        primaryKey: true,
        autoIncrement: true
      },
      depart_id: {
        type: INTEGER(30).UNSIGNED,
        comment: '部门id',
        //  定义外键（重要）
        references: {
          model: 'admin_depart', // 对应表名称（数据表名称）
          key: 'id' // 对应表的主键
        },
        onUpdate: 'restrict', // 更新时操作
      },
      phone: {
        type: STRING(100),
        allowNull: false,
        defaultValue:0,
        comment: '手机号',
      },
      pwd: {
        type: STRING(200),
        allowNull: false,
        defaultValue: '',
        comment: '密码',
      },
      avatar: {
        type: STRING(200),
        comment: '头像',
      },
      name: {
        type: STRING(100),
        allowNull: false,
        defaultValue: '',
        comment: '昵称',
      },
      roles: {
        type: STRING(200),
        allowNull: false,
        defaultValue: 'admin',
        comment: '权限',
      },
      nav_id: {
        type: STRING(200),
        allowNull: false,
        defaultValue: '',
        comment: '导航栏id',
      },
      btn_id: {
        type: STRING(200),
        allowNull: false,
        defaultValue: '',
        comment: '导航栏id',
      },
      token: {
        type: STRING(200),
        allowNull: false,
        defaultValue: '',
        comment: 'token',
      },
      status: {
        type: ENUM,
        values: ['0', '1','2'],
        allowNull: false,
        defaultValue: '1',
        comment: '状态 0离职 1在职 2删除 '
      },
      created_at: DATE,
      updated_at: DATE,
    });
  },

  down: async (queryInterface, Sequelize) => {
    await queryInterface.dropTable('admin_user');
  }
};